Skip to content

Comments

feat(lexicon): validate value on set#57828

Open
ArtificialOwl wants to merge 2 commits intomasterfrom
feat/noid/lexicon-entry-validating-value-on-set
Open

feat(lexicon): validate value on set#57828
ArtificialOwl wants to merge 2 commits intomasterfrom
feat/noid/lexicon-entry-validating-value-on-set

Conversation

@ArtificialOwl
Copy link
Member

@ArtificialOwl ArtificialOwl commented Jan 26, 2026

Adding a new parameter to Lexicon Entry so that a Closure can be set to validate the config value before storing it to database.

This would allow to use provision_api endpoints to set app/user configs while keeping an eye on its value without having a specific controller.

would be nice to have this added to next RC of 33, as it could be used to confirm the format of a string when configuring Federated Teams

@ArtificialOwl ArtificialOwl force-pushed the feat/noid/lexicon-entry-validating-value-on-set branch 3 times, most recently from 6d760bc to a9488d7 Compare January 26, 2026 19:58
@ArtificialOwl ArtificialOwl marked this pull request as ready for review January 26, 2026 21:06
@ArtificialOwl ArtificialOwl requested a review from a team as a code owner January 26, 2026 21:06
@ArtificialOwl ArtificialOwl requested review from icewind1991, leftybournes, nfebe and provokateurin and removed request for a team January 26, 2026 21:06
@ArtificialOwl ArtificialOwl added the 3. to review Waiting for reviews label Jan 26, 2026
@ArtificialOwl ArtificialOwl added this to the Nextcloud 33 milestone Jan 26, 2026
@ArtificialOwl ArtificialOwl force-pushed the feat/noid/lexicon-entry-validating-value-on-set branch from a9488d7 to 8efae41 Compare January 26, 2026 21:52
* @param int $type value type {@see VALUE_STRING} {@see VALUE_INT} {@see VALUE_FLOAT} {@see VALUE_BOOL} {@see VALUE_ARRAY}
*
* @return bool TRUE if value was updated in database
* @throws UnacceptableValueException if lexicon does not validate value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big change, you’r throwing a new Exception class.
It bubbles up to public API, no?
It should be noted on all calling methods, including in the public API.
And to not break existing code, ideally these exceptions should all inherit a common class so that calling code can be future-proof in case new ones get added later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the closure could throw that exception so that a message is added when facing a wrongly formatted value.
I can remove the exception and closure only returns true|false with no explaination of the issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this is worse, we get a silent failure now, it’s not even logged.

I’m not sure what would be better, either throw InvalidArgumentException as that’s already thrown by the same methods, or log an error to the log file.
I think it’s safer to simply log, that way when something breaks the instance is still usable, but the information is there in the log about something going wrong.

@ArtificialOwl ArtificialOwl force-pushed the feat/noid/lexicon-entry-validating-value-on-set branch 2 times, most recently from c44bb57 to d52b218 Compare January 27, 2026 11:46
@ArtificialOwl
Copy link
Member Author

  • switched to since 34
  • removing exception
  • applying requested changes

Copy link
Member

@provokateurin provokateurin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one small oversight.

This was referenced Jan 29, 2026
ArtificialOwl and others added 2 commits February 5, 2026 12:26
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Co-authored-by: Kate <26026535+provokateurin@users.noreply.github.com>
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl ArtificialOwl force-pushed the feat/noid/lexicon-entry-validating-value-on-set branch from edff996 to 1858698 Compare February 5, 2026 13:26
This was referenced Feb 11, 2026
@blizzz blizzz modified the milestones: Nextcloud 33, Nextcloud 34 Feb 16, 2026
@come-nc
Copy link
Contributor

come-nc commented Feb 23, 2026

It should log an error when validation fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants